<?php 
App::uses('RssVer2ConverterComponent', 'Controller/Component');
App::uses('RssComponent', 'Controller/Component');
App::uses('ComponentCollection', 'Controller');
class RssVer2ConverterComponentTest extends CakeTestCase{


	public function setUp(){
		parent::setUp();
		$collection = new ComponentCollection();
		$this->RssVer2Converter = new RssVer2ConverterComponent($collection);
		$this->RssComponent = new RssComponent($collection);
	}


	public function testToArticles(){
		// fetch RSS
		$url = "http://rss.rssad.jp/rss/itmatmarkit/rss.xml";//it's RSS 2.0
		$rss = $this->RssComponent->parse($url);
		// fetch articles 
		$articles = $this->RssVer2Converter->toArticles($rss);
		//assert
		$this->assertNotEmpty($articles);
		foreach($articles as $article){
			$this->assertArrayHasKey('link', $article);
			$this->assertArrayHasKey('title', $article);
			$this->assertArrayHasKey('description', $article);
		}
	}

}
?>
